package com.ruoyi.admin.train.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.train.domain.StudentInformation;
import com.ruoyi.train.domain.Vo.StudentInformationVo;
import com.ruoyi.train.service.IStudentInformationService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 学生考试合格证明审批信息Controller
 * 
 * @author wusihao
 * @date 2023-05-02
 */
@RestController
@RequestMapping("/student/examApplicationQualified")
public class examApplicationQualifiedController extends BaseController
{
    @Autowired
    private IStudentInformationService studentInformationService;

    @ApiOperation("查询学生信息")
    @GetMapping("/list/{examPassCertificateId}")
    public TableDataInfo list(@PathVariable Long examPassCertificateId)
    {
        startPage();
        return getDataTable(studentInformationService.selectStudentInformationByExamPassCertificateId(examPassCertificateId));
    }

    /**
     * 导出学员信息列表
     */
    @ApiOperation("导出学生信息")
    @Log(title = "学员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentInformation studentInformation)
    {
        List<StudentInformation> list = studentInformationService.selectStudentInformationList(studentInformation);
        ExcelUtil<StudentInformation> util = new ExcelUtil<StudentInformation>(StudentInformation.class);
        util.exportExcel(response, list, "学员信息数据");
    }

    /**
     * 获取学员信息详细信息
     */
    @ApiOperation("获取学生详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        StudentInformationVo studentInformationVo = studentInformationService.selectStudentInformationById(id);

        return success(studentInformationVo);
    }

    /**
     * 新增学员信息
     */
    @ApiOperation("新增学生信息")
    @Log(title = "学员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentInformation studentInformation)
    {
        return toAjax(studentInformationService.insertStudentInformation(studentInformation));
    }

    /**
     * 修改学员信息
     */
    @ApiOperation("修改学生信息")
    @Log(title = "学员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentInformation studentInformation)
    {
        return toAjax(studentInformationService.updateStudentInformation(studentInformation));
    }

    /**
     * 删除学员信息
     */
    @ApiOperation("删除学生信息")
    @Log(title = "学员信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(studentInformationService.deleteStudentInformationByIds(ids));
    }
}
